{extend name="public/base"}
{block name="head"}
<style>
    .cover{
        position: absolute;
        background-color: rgba(0,0,0,0.6);
        color: seashell;
        padding: 5px 10px;
        margin-top:10px;
    }
</style>
{/block}
{block name="main"}
<div class="container" id="main">
    <div class="text-right">
        <button class="btn btn-primary btn-sm"><a href="{:url('album/add',['id'=>$list.id])}">图片上传</a></button> <button class="btn btn-primary btn-sm"><a href="{:url('album/create')}">创建相册</a> </button>
    </div>
    <legend>{$cover.subject}</legend>
    <div class="row">
        {volist name="list.list" id="vo"}
        <div class="col-sm-6 col-md-3">
            <div class="thumbnail">
                {if condition="$cover.cover_id eq $vo.id "}<div class="cover">封面</div>{/if}
                <img  src="/{$vo.thumb_path}{$vo.file_name}" alt="通用的占位符缩略图">
                <div class="caption">
                    <h3>缩略图标签</h3>
                    <p>一些示例文本。一些示例文本。</p>
                    {if condition="$cover.cover_id neq $vo.id "}
                    <p>
                        <button  @click="cover({$vo.f_id},{$vo.a_id})" class="btn btn-default" role="button">
                            设为封面
                        </button>
                        <button  @click="del({$vo.id})" class="btn btn-danger" role="button">
                            删除
                        </button>
                    </p>
                    {/if}
                </div>
            </div>
        </div>
        {/volist}
    </div>
    <div>{$list.page|raw}</div>
</div>

<script>
    new Vue({
        el:'#main',
        methods:{
            del:function(id){
              layer.alert('are you sure?',function(){
                  var url = "/admin/album/del";
                  var data = {id:id};
                    ajax(url,data,'get',function(e){if(e.status == 1) window.location.reload();});
              })
            },
            cover:function(id,album_id){
                var url = "/admin/album/cover";
                var data = {id:id,album_id:album_id};
                ajax(url,data,'POST',function(e){
                   if(e.status == 1){
                       layer.msg('设置成功',function(){
                           window.location.reload();
                       });
                   }
                })
            }
        }
    })

</script>

{/block}

